package com.foreknow.demo5;

/**
 * 构造器(构造函数/构造方法)
 */
public class ConstrctorDemo1 {

    private String name;
    private int age;
    private String[] strs;
    private Employee sta;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //通过构造器来初始化属性
    public ConstrctorDemo1(String name, int age) {
        this.name = name;
        this.age = age;
        strs = new String[10];
        sta = new Employee();
        //System.out.println("构造器的作用是初始化的...");
    }  //构造器

    public static void main(String[] args) {
        ConstrctorDemo1 c = new ConstrctorDemo1("tom",20);
        System.out.println(c.getName());
        System.out.println(c.getAge());

    }
}









